/**
 *    Copyright (C) 2009  Victor Smirnov <aist11@gmail.com>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *    See LICENSE.exceptions in the root folder of this project for possible
 *    exceptions
 *
 */

#ifndef _CUBEFS_CORE_CONTAINER_MACROS_HPP
#define	_CUBEFS_CORE_CONTAINER_MACROS_HPP

#define CUBEFS_TYPE_FACTORY_BEGIN(ProfileName, FactoryName)                     \
template <typename Profile, typename Default>                                   \
class TypeFactory<ProfileName, Profile, FactoryName, Default>      {


#define CUBEFS_TYPE_FACTORY_BEGIN1(ProfileName, FactoryName, Param)             \
template <typename Profile, typename Default, typename Param>                   \
class TypeFactory<ProfileName, Profile, FactoryName< Param >, Default>      {

#define CUBEFS_TYPE_FACTORY_END };





#define CUBEFS_CONTAINER_PART_NO_CTR_BEGIN(PartName)               				\
template <typename MyType, typename Base>                     					\
class ContainerPart<PartName, MyType, Base>: public Base {						\
    MyType& me_;                                                                \
public:                                                                         \



#define CUBEFS_CONTAINER_PART_BEGIN(PartName)                      				\
    CUBEFS_CONTAINER_PART_NO_CTR_BEGIN(PartName)                   				\
    ContainerPart(MyType &me): Base(me), me_(me)  {}                            \
    MyType &me() {                                                              \
        return me_;                                                             \
    }                                                                           \
                                                                                \
    const MyType &me() const {                                                  \
        return me_;                                                             \
    }                                                                           \

#define CUBEFS_CONTAINER_PART_END };




#define CUBEFS_PAGE_PART_BEGIN(PartName)                                   				\
template <typename BaseType>                                          					\
class PagePart<PartName, BaseType>: public BaseType {             						\
public:                                                                                 \
    typedef BaseType                                                            Base;   \
    typedef PagePart<                                                                   \
                PartName,                                                               \
                BaseType                                                                \
    >                                                                           Me;



#define CUBEFS_PAGE_PART_BEGIN1(PartName, Param)                           				\
template <typename Param, typename BaseType>                          					\
class PagePart<PartName<Param>, BaseType>: public BaseType {    						\
public:                                                                                 \
    typedef BaseType                                                            Base;   \
    typedef PagePart<                                                                   \
                PartName< Param >,                                                      \
                BaseType                                                                \
    >                                                                           Me;




#define CUBEFS_PAGE_PART_BEGIN2(PartName, Param)                           				\
template <Param, typename BaseType>                                  	 				\
class PagePart<PartName, BaseType>: public BaseType {             						\
public:                                                                                 \
    typedef BaseType                                                            Base;   \
    typedef PagePart<                                                                   \
                PartName,                                                               \
                BaseType                                                                \
    >                                                                           Me;


#define CUBEFS_PAGE_PART_END };



#define CUBEFS_MODEL_PART_NO_CTR_BEGIN(PartName)                   				\
template <typename MyType, typename Base>                 						\
class ModelPart<PartName, MyType, Base>: public Base {							\
    MyType& me_;                                                                \
public:



#define CUBEFS_MODEL_PART_BEGIN(PartName)                          				\
    CUBEFS_MODEL_PART_NO_CTR_BEGIN(PartName)                       				\
    ModelPart(MyType &me): Base(me), me_(me)  {}                                \
    MyType &me() {                                                              \
        return me_;                                                             \
    }                                                                           \
                                                                                \
    const MyType &me() const {                                                  \
        return me_;                                                             \
    }                                                                           \

#define CUBEFS_MODEL_PART_END };



#define CUBEFS_ITERATOR_PART_NO_CTOR_BEGIN(PartName)               				\
template <typename MyType, typename Base>                     					\
class IteratorPart<PartName, MyType, Base>: public Base { 						\
    MyType& me_;                                                                \
public:



#define CUBEFS_ITERATOR_PART_BEGIN(PartName)                       				\
    CUBEFS_ITERATOR_PART_NO_CTOR_BEGIN(PartName)                   				\
    IteratorPart(MyType &me): Base(me), me_(me) {}

#define CUBEFS_ITERATOR_PART_END };




#endif
